﻿using System;

namespace Timer
{
    class Timer
    {
        DateTime startTime;
        DateTime endTime;
        TimeSpan difference;
        bool isActive = false;

        public void Start()
        {
            if (!isActive)
            {
                startTime = DateTime.Now;
                Console.WriteLine("Start: {0}", startTime.ToString("HH:mm:ss.FFF"));
                isActive = true;
            }
            else
            {
                Console.WriteLine("Видишь, работает? Не мешай ему");
            }
        }

        public int Stop()
        {
            endTime = DateTime.Now;
            isActive = false;
            difference = difference + (endTime - startTime);
            Console.WriteLine("Finish: {0}", endTime.ToString("HH:mm:ss.FFF"));
            Console.WriteLine("Iteration: {0}", (endTime - startTime).ToString(@"hh\:mm\:ss\.fff"));
            Console.WriteLine("Totally: {0}", difference.ToString(@"hh\:mm\:ss\.fff"));
            return difference.Seconds;
        }

        public void Reset()
        {
            difference = TimeSpan.Zero;
            Console.WriteLine("Секундомер обнулен");
        }
    }
}
